// 暴力解法
class Solution {
public:
    int removeElement(vector<int>& nums, int val) {
        int index = 0;
        int size = nums.size();
        while(index < size){
            if(nums[index] == val){
                for(int j = index; j < size - 1; ++j){
                    nums[j] = nums[j + 1];
                }
                --size;
            } else {
                ++index;
            }
        }

        return size;
    }
};

// 双指针解法
class Solution {
public:
    int removeElement(vector<int>& nums, int val) {
        int from = 0;
        int to = 0;
        while(from < nums.size()){
            if(nums[from] != val){
                nums[to++] = nums[from++];
            } else {
                from++;
            }
        }

        return to;
    }
};